package com.songlanyun.common.utils.logistics;

import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONArray;
import com.songlanyun.common.utils.StreamUtils;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.io.*;

/**
 * @author wuchao
 * @date
 */
@Component
public class LogisticsUtil {

    @Value("${logistics.company.path}")
    private String logisticsCompanyPath;

    /**
     *  获取物流公司
     */
    public JSONArray get() {
        FileInputStream fileInputStream = null;
        try {
            fileInputStream = new FileInputStream(logisticsCompanyPath);
            if (ObjectUtil.isNull(fileInputStream)) {
                return null;
            }
            return JSONArray.parseArray(StreamUtils.inputStreamToString(fileInputStream));
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        return null;
    }

}
